#include<bits/stdc++.h>
using namespace std;
int n,ha[2][100005],maxn=-1;
int main(){
    freopen("duel.in","r",stdin);
    freopen("duel.out","w",stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    for(int i = 1;i<=n;i++){
        int x;
        cin>>x;
        ha[0][x]++;
        ha[1][x]++;
        maxn = max(maxn,x);
    }
    int left = 0,right = 1;
    while(right<=maxn){
        if(ha[0][left]==0){
            for(int j = left+1;j<=maxn;j++){
                if(ha[0][j]!=0){
                    left=j;
                    break;
                }
            }
            if(ha[0][left]==0)break;
        }
        else if(ha[1][right]==0){
            for(int j = right+1;j<=maxn;j++){
                if(ha[1][j]!=0){
                    right=j;
                    break;
                }
            }
            if(ha[1][right]==0)break;
        }
        else if(left>=right){
            right=left+1;
        }
        else{
            int minn = min(ha[0][left],ha[1][right]);
            ha[0][left]-=minn;
            ha[1][right]-=minn;
            ha[1][left]-=minn;
            n-=minn;
        }
    }
    cout<<n<<"\n";
    return 0;
}
